package com.xindaoapp.happypet.ui;

import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.view.View.OnClickListener;

import com.xindaoapp.happypet.R;
import com.xindaoapp.happypet.adapter.CommonViewPagerAdapter;
import com.xindaoapp.happypet.fragments.MyAttentionFragment;
import com.xindaoapp.happypet.fragments.MyFansFragment;

/**
 * 设置-我的好友
 * 
 * @author xindaoapp
 * 
 */
public class MyFriendActivity extends BaseActivity implements OnClickListener {

    private ViewPager vViewPager;

    @Override
    protected int getContentViewResId() {
        return R.layout.activity_myfriend;
    }

    @Override
    protected void initViews() {
        super.initViews();
        vViewPager = (ViewPager) findViewById(R.id.viewpager);
        Fragment[] fragments =
                new Fragment[] {MyAttentionFragment.newInstance(null, false),
                        MyFansFragment.newInstance(false)};
        View[] tabViews =
                new View[] {findViewById(R.id.tab_left_view), findViewById(R.id.tab_right_view)};
        CommonViewPagerAdapter adapter =
                new CommonViewPagerAdapter(getSupportFragmentManager(), fragments, tabViews);
        for (int i = 0; i < tabViews.length; i++) {
            final int temp = i;
            tabViews[i].setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    vViewPager.setCurrentItem(temp);
                }
            });
        }
        vViewPager.setAdapter(adapter);
        vViewPager.setOffscreenPageLimit(2);
        vViewPager.setOnPageChangeListener(adapter);
    }

    @Override
    public void onClick(View v) {

    }

    @Override
    protected OnClickListener getLeftViewClickListener() {
        return new OnClickListener() {

            @Override
            public void onClick(View v) {
                finish();
            }
        };
    }

    @Override
    protected int getTopBarLeftImageViewRes() {
        return R.drawable.top_bar_back;
    }

    @Override
    protected String getTopBarTitleStrRes() {
        return "我的好友";
    }

}
